<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算年龄小游戏</title>

    <script>
        function age() {
            var year = prompt("请输入您的出生年份")
            if (year != null && year != "" && year <= 2019) {
                document.write("您今年" + (2019 - year) + "岁")
            }
        }
    </script>
</head>
<div onclick="javascript:age()">计算年龄</div>

<body>

</body>

</html>